package com.example.lin.week2project.utils;

import android.content.Context;

import java.io.File;

public class JsonCache {


    private static final String FILE_NAME = "json.txt";

    public static boolean saveJson(Context context, String json) {
        File cacheDir = context.getCacheDir();
        File saveFile = new File(cacheDir, FILE_NAME);
        return FileUtils.writeText2File(saveFile, json);
    }

    public static String getJson(Context context) {
        File cacheDir = context.getCacheDir();
        File saveFile = new File(cacheDir, FILE_NAME);
        if (saveFile.exists())
            return FileUtils.readTextFromFile(saveFile);
        return null;
    }


}
